package com.yupi.yuojbackendjudgeservice;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

/**
 * @Author FengHuan Wang
 * @Date 2025/3/17 8:54
 * @Version 1.0
 */
public class InitMq {
    public static void main(String[] args) {
        try {
            ConnectionFactory connectionFactory = new ConnectionFactory();
            connectionFactory.setHost("124.70.111.229");
            connectionFactory.setUsername("admin");
            connectionFactory.setPassword("123456");
            Connection connection = connectionFactory.newConnection();
            Channel channel = connection.createChannel();
            String exchangeName = "yuoj";
            channel.exchangeDeclare(exchangeName, "direct");
            //创建你队列，随机分配一个队列名称
            String queueName = "yuoj";
            channel.queueDeclare(queueName, true, false, false, null);
            channel.queueBind(queueName, exchangeName, "yuoj");
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
